// 仅选择日期
$(".form-date").datetimepicker({
        language:  "zh-CN",
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
        format: "yyyy-mm-dd"
    });
/*解析href*/
var str = location.search;
str = str.slice(1).split('&');
var json = {};
for (var i = 0; i < str.length; i++){
    var a = str[i].split('=');
    json[a[0]] = a[1];
}
//console.log(json);

$(function () {
    //init();/*初始化*/
    $('#addClick').click(function(){
        //获得当前工人userCode  teamId  projectCode
        layer.open({
            type: 2,
            maxmin: false,
            shadeClose: false,
            closeBtn: 1,
            area : ['30%' , '80%'],
            content:`worker-inner.html?projectCode=${json.projectCode}&teamId=${json.teamId}&userCode=${json.userCode}`,
            title :　false,
            end:function(){
                $("#workTable").bootstrapTable('refresh','http://192.168.59.3:8082/console/projectmgt/attendance/detail');
            }
        });
    });
});


/*分页器*/
function workTableQuery(params){
    params["pageNum"] = (params.offset / params.limit) + 1;
    params.pageSize = params.limit;
    params.relationId= 27;
    params.userCode= "abc1001";
    return params;
}

function handlerFmt(value,row){
    //console.log(row);
    return `<span onclick="oEditFun('${json.projectCode}','${json.teamId}','${json.userCode}','${row.changeReason}','${row.chgWorkTime}','${row.chgWorkTimeAdjust}','${row.chgWorkTimeEnd}','${row.chgWorkTimeStart}','${row.dataTime}','${row.unitSalary}','${row.orgWorkTimeEnd}','${row.orgWorkTimeStart}')" class='edit'>编辑</span><span onclick="oDelFun('${row.id}')" class='del'>删除</span>`
}
function oEditFun(code1,code2,code3,code4,code5,code6,code7,code8,code9,code10){
    layer.open({
        type: 2,
        maxmin: false,
        shadeClose: true,
        closeBtn: 1,
        area : ['30%' , '80%'],
        content:`../worker-att-detail/worker-inner.html?edit=1&projectCode=${code1}&teamId=${code2}&userCode=${code3}&changeReason=${code4}&chgWorkTime=${code5}&chgWorkTimeAdjust=${code6}&chgWorkTimeEnd=${code7}&chgWorkTimeStart=${code8}&dataTime=${code9}&unitSalary=${code10}`,
        title :　false,
        end:function(){
            $("#workTable").bootstrapTable('refresh','http://192.168.59.3:8082/console/projectmgt/attendance/detail');
        }
    });
}

function oDelFun (code1){
    $.get('http://192.168.59.3:8082/console/projectmgt/attendance/'+ code1 +'/invalid' )
    $('#workTable').bootstrapTable('refresh','http://192.168.59.3:8082/console/projectmgt/attendance/detail')
}
function responseHandler(res){
    var needData = {
        rows: res.data.list,
        total: res.data.total
    };
    return needData;
}
